<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:local="clr-namespace:UColor.WPF.Helpers">

    <dx:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <Style TargetType="local:PopupControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PopupControl">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="1" Width="{Binding LeftOffset, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Grid Grid.Row="1" Grid.Column="2" Width="{Binding RightOffset, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Grid Grid.Column="1" Height="{Binding TopOffset, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Grid Grid.Column="1" Grid.Row="2" Height="{Binding BottomOffset, RelativeSource={RelativeSource TemplatedParent}}" />
                            <Border x:Name="Border" Grid.Column="1" Grid.Row="1" Visibility="{Binding Path=IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <Grid x:Name="ContentContainer" MaxHeight="{TemplateBinding MaxHeight}" MaxWidth="{TemplateBinding MaxWidth}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <ContentPresenter />
                                </Grid>
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="local:DemoSplashScreenControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:DemoSplashScreenControl">
                    <local:PopupControl x:Name="PopupControl" IsOpen="{Binding IsSplashScreenVisible, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center">
                        <local:PopupControl.Resources>
                            <Style x:Key="ThemeSelectingSplashScreenControl" TargetType="local:SimpleControl">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="local:SimpleControl">
                                            <Grid x:Name="Message" Width="300" Height="150">
                                                <Grid Margin="6,4,6,5">
                                                    <Border Background="Black" CornerRadius="3" Opacity="0.15" />
                                                    <Border CornerRadius="2" Margin="1" Background="White" />
                                                </Grid>
                                                <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="Please wait while the theme is being applied" VerticalAlignment="Center" FontSize="14" Foreground="DarkGray" />
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </local:PopupControl.Resources>
                        <local:SimpleControl Style="{StaticResource ThemeSelectingSplashScreenControl}" />
                    </local:PopupControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
